<?php
    session_start();
    include_once '../../ConfigSite/DataBase/DB_Conexion.php';
    include_once '../Model/mdl_login.php';
    include '../../Resources/encriptar/encriptar.php';
    
    $conn = new DB_Conexion(2);
    $model = new mdl_login($conn->db);
    
    if (isset($_POST['usuario']) and isset($_POST['password']) ) {
        $encriptar =  new Encryption();
        $pass = $encriptar->encode($_POST['password']);
        $tipoUsuario = $model->ValidarUsuario($_POST['usuario'], $pass);
        $result = $model->MostrarUusario();
        if (sizeof($result) > 0 and $result !=="null") {
            $_SESSION["Usuario"] = $result[0]['Nombre']." ". $result[0]['Apellido1'];
            $_SESSION["TipoUsuario"] = $tipoUsuario[0]['TipoUsuario'];
            $_SESSION["NowTime"] = time();
            echo "true";
            
        }  else {
            
            echo 'falso';
        }
        
    }  else {
        
        echo 'falso';
        
    }


?>
